 <meta charset="utf-8">
 <div class="card" id="biz_aIConfigCate_conatainer" style="padding-bottom: 0px;">
 
   
 <div class="card">
 	<div class="card-body">
 	<div class="row">
 	
 	  <div class="col-md-3">
             <div class="table-responsive">
                                            <table class="table mb-0">
                                                <thead>
                                                    <tr>
                                                        <th><div class="alert alert-danger mb-0" role="alert">点击配置类别，请在右侧进行配置编辑</div></th>
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                    <tr v-for="(cate,index) in cateList">
                                                        <td><button class="btn btn-outline btn-primary btn-block" v-on:click="loadItems(cate)">{{cate.name}}</button></td>
                                                    </tr>
                                                </tbody>
                                            </table>
             </div>
 	  </div>
 	  
 	  
 	  <div class="col-md-9">
 	  
 	  						<div class="alert alert-warning" role="alert" v-if="nowcate.name">
                                          		    当前选择配置类别：<font color="red"><strong>【{{nowcate.name}}】</strong> </font>
                                          		    
                                   <button type="button"  v-kperms="{perm:''}" class="btn btn-info float-right" style="margin-top:-7px;" v-on:click="add()">
                                        <i class="ti-plus" aria-hidden="true" ></i> 添加
                                    </button>
                           </div>
                                            
           

  									<div class="table-responsive">
                                            <table class="table mb-0">
                                                <thead>
                                                    <tr>
                                                        <th>#</th>
                                                        <th>编码</th>
                                                        <th>名称</th>
                                                        <th>状态</th>
                                                        <th>备注</th>
                                                        <th>操作</th>
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                    <tr  v-for="(item,index) in itemList">
                                                        <th scope="row">{{index+1}}</th>
                                                        <td>{{item.code}}</td>
                                                        <td>{{item.name}}</td>
                                                        <td> <span v-if="item.status==0" class="btn btn-sm btn-warning">禁用</span> <span  v-if="item.status==1"  class="btn btn-sm btn-success">正常</span></td>
                                                        <td>{{item.remark}}</td>
                                                        <td>
                                                        
                                                        <div class="btn-group" id="authaIConfigCateTableToolbar"  role="toolbar">
							                                    
							                                     <button type="button "  v-kperms="{perm:''}" class="btn btn-sm btn-warning" v-on:click="edit(item.id)">
							                                        <i class="ti-pencil" aria-hidden="true"></i> 修改
							                                    </button>
							                                    
							                                     <button type="button"  v-kperms="{perm:''}" class="btn  btn-sm btn-info" v-on:click="setEnable(item.id,1)">
							                                        <i class="ti-check" aria-hidden="true"></i> 启用
							                                    </button>
							                                     <button type="button"  v-kperms="{perm:''}" class="btn btn-sm  btn-danger" v-on:click="setEnable(item.id,0)">
							                                        <i class="ti-power-off" aria-hidden="true"></i> 禁用
							                                    </button>
							                           </div>
							                           
                                                        
                                                        </td>
                                                    </tr>
                                                   
                                                </tbody>
                                            </table>
                                        </div>
                                        
                                        <div class="alert alert-warning" role="alert" v-if="nowcate.name && itemList.length>12">
                                          		    当前选择配置类别：<font color="red"><strong>【{{nowcate.name}}】</strong> </font>
		                                          		    
		                                   <button type="button"  v-kperms="{perm:''}" class="btn btn-info float-right" style="margin-top:-7px;" v-on:click="add()">
		                                        <i class="ti-plus" aria-hidden="true" ></i> 添加
		                                    </button>
		                           </div>
                           
                                        
                                        
 	  </div>
 	</div>
 	</div>
 	</div>
 	
 </div>
<script>
var anewaz=new Vue({  
	  el: '#biz_aIConfigCate_conatainer', 
	  data:{
		  searchForm:{
			  name: null,
			  status: null
		  },
		  nowcate:{},
		  cateList:[],
		  itemList:[],
	      bus:new Vue()
	  },
	  mounted:function(){
		 var _this=this;
		
		 _this.initCateTable();
	  },

    methods: {
     	 initCateTable: function(){
      		 var　_this=this;
      		 var url="/xzy/aIConfigCate/loadAllAIConfigCate";
      		
 		    zfesAjax.ajaxTodo(url, {"status":1}, function(data) {
 				_this.cateList=data.data.cateList;
 				if(_this.cateList&&_this.cateList.length>0){
 					_this.nowcate=_this.cateList[0];
 					_this.loadItems(_this.nowcate);
 				}
 				
 			});
     	 },
     	loadItems: function(cate){
     		 var _this=this;
     		 _this.nowcate=cate;
     		 var url="/xzy/aIConfigItem/loadItemByCate";
     		zfesAjax.ajaxTodo(url, {cateId:cate.id}, function(data) {
 				_this.itemList=data.data.itemList;
 			});
     	},
  	  formatLink: function(value, row, index ){
  		  return '<a href=\"javascript:void(0);\"  onclick=\"showDetail('+row+')\" >'+value+'</a>';
  	  },
      formatStatus: function(value, row, index ){
    	  if(0==value){
    		  return '<span class="btn btn-sm btn-warning">禁用</span>';
    	 }if(1==value){
    		  return '<span class="btn btn-sm btn-success">正常</span>';
    	 }else{return value;}
	  }, 
	  refresh:function(){
		  var　_this=this;
		  _this.loadItems(_this.nowcate);
	  },
	  
  	add: function(){
 		 var　_this=this;
 		 var url="/view/aIConfigCateItem/aIConfigCateItem.add.html";
 		 zfesLayerEditDg.open(url,{cateId: _this.nowcate.id},"编辑",460,function(){_this.refresh();});
 		 
 	  },
 	  edit: function(itemId,id){
 		 var　_this=this;
 		 	 var url="/view/aIConfigCateItem/aIConfigCateItem.edit.html";
			  zfesLayerEditDg.open(url,{"id":itemId},"编辑",460,function(){_this.refresh();}); 
 	  },
 	 doDelete: function(itemId){
 		 var　_this=this;
 		 alertSwal.confirm("删除","是否删除该数据",function(){
			    var ajaxUrl = "/xzy/aIConfigItem/deleteAIConfigCate";
				zfesAjax.ajaxTodo(ajaxUrl, { "id" : id}, function(data) {
					alertSwal.successText(data.message);
					_this.refresh();
				},function(data){
					
				}); 
	});
 		
	},
	
	  setEnable: function(itemId,status){
		  var _this=this;
			 alertSwal.confirm("启用","是否执行该操作",function(){
				    var ajaxUrl = "/xzy/aIConfigItem/setAIConfigItemStatus";
				    zfesAjax.ajaxTodo(ajaxUrl, { "id" : itemId,"status":status}, function(data) {
						alertSwal.successText(data.message);
						_this.refresh();
					});
				});
	  }
	  
   	
   }

});

function showDetail(row){
	anewaz.showDetail(row);
}
</script>


